var app = getApp();

Page({
    data: {
        navH: 0,
        uInfo: !1,
        money: "",
        btnDis: !1,
        focus: !1,
        min_withdrawal_money: 0,
        withdrawal_method: 0
    },
    showInfo: function() {
        app.showInfo(this, app.globalData.setting.withdrawl_rule_intro);
    },
    hideInfo: function() {
        app.hideInfo(this);
    },
    loginAfter: function(a) {
        app.loginAfter(a);
    },
    loginCancel: function() {
        app.loginCancel();
    },
    choosePic: function(a) {
        var o;
        app.globalData.userInfo ? (a.currentTarget.dataset.field, o = this, wx.chooseImage({
            count: 1,
            sizeType: [ "compressed" ],
            sourceType: [ "album" ],
            success: function(a) {
                var t = a.tempFilePaths[0];
                wx.compressImage({
                    src: t,
                    quality: 80,
                    complete: function() {
                        wx.uploadFile({
                            url: app.util.url("entry/wxapp/uploadTempPic"),
                            filePath: t,
                            name: "pic",
                            header: {
                                "content-type": "multipart/form-data"
                            },
                            success: function(a) {
                                console.log(a), 0 == (a = JSON.parse(a.data)).errno ? o.setData({
                                    withdrawal_qrcode: a.data.path
                                }) : wx.showToast({
                                    title: a.message,
                                    icon: "none",
                                    duration: 2e3
                                });
                            }
                        });
                    }
                });
            }
        })) : app.checkLogin();
    },
    setMoney: function(a) {
        if (100 * (n = a.detail.value) > 100 * this.data.uInfo.money) this.wholeMoney(); else {
            if (-1 != n.indexOf(".")) for (var t = [ [ "^0(\\d+)$", "$1" ], [ "[^\\d\\.]+$", "" ], [ "\\.(\\d?)\\.+", ".$1" ], [ "^(\\d+\\.\\d{2}).+", "$1" ] ], o = 0; o < t.length; o++) var e = new RegExp(t[o][0]), n = n.replace(e, t[o][1]);
            this.setData({
                money: n
            });
        }
    },
    wholeMoney: function() {
        this.setData({
            money: parseFloat(this.data.uInfo.money),
            focus: !1
        });
    },
    navBack: function() {
        wx.navigateBack();
    },
    onLoad: function(a) {
        console.log("options", a), this.setData({
            navH: app.globalData.navHeight
        }), app.globalData.userInfo && this.setData({
            uInfo: app.globalData.userInfo
        }), this.setData({
            withdrawal_apply_rate: app.globalData.setting.withdrawal_apply_rate,
            withdrawal_apply_switch: app.globalData.setting.withdrawal_apply_switch,
            withdrawal_method: app.globalData.setting.withdrawal_method,
            withdrawal_apply_open: app.globalData.setting.withdrawal_apply_open,
            min_withdrawal_money: app.globalData.setting.min_withdrawal_money
        }), app.checkUserSub(3);
    },
    toWithDrawal: function(a) {
        var t, o;
        app.globalData.userInfo ? (t = a.detail.formId, (o = this).data.money ? o.data.uInfo.money ? 100 * o.data.uInfo.money < 100 * o.data.money ? wx.showToast({
            title: "您的提现金额大于当前可提现余额",
            icon: "none"
        }) : o.data.money < parseFloat(o.data.min_withdrawal_money) ? wx.showModal({
            title: "系统提示",
            content: "提现金额不能低于" + o.data.min_withdrawal_money + "元，快去推广商品赚钱吧~",
            showCancel: !0,
            cancelColor: "#cccccc",
            confirmColor: "#f43f6c",
            confirmText: "去赚钱",
            success: function(a) {
                a.confirm && wx.navigateBack();
            }
        }) : 1 != o.data.withdrawal_method || o.data.withdrawal_qrcode ? wx.showModal({
            title: "系统提示",
            content: "确认要进行提现吗？该操作无法撤消",
            showCancel: !0,
            cancelColor: "#f43f6c",
            confirmColor: "#cccccc",
            confirmText: "确定",
            success: function(a) {
                a.confirm && !o.data.btnDis && (o.setData({
                    btnDis: !0
                }), app.util.request({
                    url: app.util.url("entry/wxapp/withdrawalMoney"),
                    data: {
                        money: o.data.money,
                        withdrawal_qrcode: o.data.withdrawal_qrcode || "",
                        formId: t
                    },
                    success: function(a) {
                        var t = 1 != o.data.withdrawal_apply_open && 1 != o.data.withdrawal_method ? "提现成功，稍候系统自动会为您处理提现请求，请注意查看收款通知" : "您的提现申请已提交成功，我们会在1-3个工作日内处理您的提现请求";
                        wx.showModal({
                            title: "系统通知",
                            content: t,
                            showCancel: !1,
                            confirmColor: "#f43f6c",
                            confirmText: "朕知道了",
                            success: function() {
                                wx.navigateBack();
                            }
                        });
                    },
                    complete: function() {
                        o.setData({
                            btnDis: !1
                        });
                    }
                }));
            }
        }) : wx.showToast({
            title: "请上传您的微信收款二维码，以便为您的提现转账",
            icon: "none"
        }) : wx.showToast({
            title: "您的可提现余额为0",
            icon: "none"
        }) : wx.showToast({
            title: "请输入您要提现的金额",
            icon: "none"
        })) : app.checkLogin();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        var a = app.globalData.setting.share_title || "购物省钱，分享赚钱", t = app.globalData.setting.share_pic;
        return {
            title: a,
            path: "/first_duoduoke/pages/index/index" + (void 0 !== app.globalData.userInfo.uid ? "?from_uid=" + app.globalData.userInfo.uid + "&from_act=share" : ""),
            imageUrl: t,
            success: function(a) {
                "shareAppMessage:ok" == a.errMsg ? wx.showToast({
                    title: "分享成功",
                    icon: "success"
                }) : wx.showToast({
                    title: "分享失败",
                    icon: "none"
                });
            },
            fail: function(a) {
                "shareAppMessage:fail cancel" == a.errMsg || a.errMsg, wx.showToast({
                    title: "分享失败",
                    icon: "none"
                });
            }
        };
    }
});